


//
//  PostCheckTool.m
//  PostDelivery
//
//  Created by wmz on 2020/7/21.
//  Copyright © 2020 wmz. All rights reserved.
//

#import "PostCheckTool.h"

@implementation PostCheckTool
//检测手机号
+ (BOOL)checkMobile:(NSString *)mobile{
    if (!mobile) return NO;
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", @"^([0-9]){11}$"];
    return [pred evaluateWithObject:mobile];
}
//检测身份证
+ (BOOL)checkIDCard:(NSString *)IDCard{
    if (!IDCard) return NO;
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", @"^(([0-9]{15})|([0-9]{18})|([0-9]{17}[xX]))$"];
    return [pred evaluateWithObject:IDCard];
}
//检测是否有空格
+ (BOOL)checkExistEmpty:(NSString*)string{
    if (!string) return YES;
    if (string.length == 0) return NO;
    if(![string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]].length) {
        return YES;
    }
    return NO;
}
//检测邮箱
+ (BOOL)checkEmail:(NSString*)email{
    if (!email) return NO;
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"];
    return [pred evaluateWithObject:email];
}
@end
